package com.luculent.util.extension.validator.constraintvalidation;

import cn.hutool.core.lang.Validator;
import com.luculent.util.extension.validator.constraints.Letter;
import org.apache.commons.lang3.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * 
 *验证字符串是否全部为字母组成，包括大写和小写字母和汉字
 *@author: zhangyang
 *@since: 2019年1月31日下午4:19:58
 */
public class LetterValidator implements ConstraintValidator<Letter, String> {

	@Override
	public boolean isValid(String value, ConstraintValidatorContext context) {
		if(StringUtils.isEmpty(value)) {
			return true;
		}
		return Validator.isLetter(value);
	}

	@Override
	public void initialize(Letter constraintAnnotation) {
		// TODO Auto-generated method stub
		
	}

}
